package com.ryskoo.catering.productimage.service;

import com.ryskoo.catering.productimage.domain.ProductImagePO;
import com.ryskoo.catering.productimage.repository.IProductImageRepository;
import com.ryskoo.framework.core.service.BasicServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.PostConstruct;
import java.util.List;

@Service
@Transactional
public class ProductImageServiceImpl extends BasicServiceImpl<ProductImagePO> implements IProductImageService{

    @Autowired
    private IProductImageRepository productImageRepository;

    @PostConstruct
    public void init(){
        this.setDao(productImageRepository);
    }

    @Override
    public void deleteByMainUuid(String mainUuid) {
        productImageRepository.deleteByMainUuid(mainUuid);
    }

    @Override
    public void deleteByMainUuids(List<String> mainUuids) {
        productImageRepository.deleteByMainUuids(mainUuids);
    }

    @Override
    public List<ProductImagePO> getImagesByMainUuid(String mainUuid) {
        return productImageRepository.getImagesByMainUuid(mainUuid);
    }
}
